package edu.ccut.saturn.basecomponent.database.impl.sqlserver.builder.unused;

import edu.ccut.saturn.basecomponent.database.ISaturnSQL;
import edu.ccut.saturn.basecomponent.database.SaturnSQLBuilderFactory;
import edu.ccut.saturn.basecomponent.database.impl.AbstractInsertSQLBuilder;
import edu.ccut.saturn.basecomponent.database.impl.db2.DB2Attribute;
import edu.ccut.saturn.component.IDataItem;

public class DB2InsertSQLBuilder extends AbstractInsertSQLBuilder {

	@Override
	protected String getColumnValueString(IDataItem iDataItem, Object value) {
		String type = iDataItem.getType();
		StringBuffer sqlAppend = new StringBuffer();
        //DB2时间不需要使用to_date
//		if ("DATE".equals(type)) {
//			return sqlAppend.append("to_date('").append(value).append(
//					"', 'yyyy-mm-dd hh24:mi:ss'), ").toString();
//		}

		return sqlAppend.append(DB2Attribute.quote(type)).append(value) 
				.append(DB2Attribute.quote(type)).append(", ").toString(); 
	}

	@Override
	protected String getPrimerKeySql(IDataItem dataItem) {
		return "SELECT nextval for " + dataItem.getSequenceName() + " primaryKey from sysibm.sysdummy1";
	}

	@Override
	protected String getDatabaseType() {
		return SaturnSQLBuilderFactory.DB2;
	}

	@Override
	protected String getOperationType() {
		return ISaturnSQL.INSERT_OPERATION;
	}

}
